/**
 * 
 */
package org.sgt.datamodel.edit.provider;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.edit.provider.INotifyChangedListener;
import org.sgt.datamodel.Action;
import org.sgt.datamodel.DatamodelPackage;
import org.sgt.datamodel.util.ActionHelper;

/**
 * @author BUTTIGHOFFER-A
 *
 */
public class SpecificationChangeListener implements INotifyChangedListener {

	/* (non-Javadoc)
	 * @see org.eclipse.emf.edit.provider.INotifyChangedListener#notifyChanged(org.eclipse.emf.common.notify.Notification)
	 */
	@Override
	public void notifyChanged(Notification notification) {
		Object notifier = notification.getNotifier();
		if(notifier instanceof Action && notification.getEventType() == Notification.SET 
				&& notification.getOldValue() == null
				&& notification.getNewValue() != null) {
			if (DatamodelPackage.eINSTANCE.getAction_Specification() == notification.getFeature()){
				Action changed = (Action) notifier;
				ActionHelper.buildFromSpecification(changed);
			}
		}
	}

}
